#include<bits/stdc++.h>
using namespace std;

int solution(int n, vector<vector<int>> &a)
{
    for(int i = 1;i < n;i++)
    {
    	for(int j = 0;j <= i;j++)
    	{
    		if(!j)
    			a[i][j] += a[i-1][j];
    		else if(j != i)
	    		a[i][j] += max(a[i-1][j], a[i-1][j-1]);
	    	else
	    		a[i][j] += a[i-1][j-1];
		}
	}
        
    if(n&1)
        return a[n-1][n/2];
    else
        return max(a[n-1][n/2], a[n-1][n/2-1]);
}

int main()
{
	int n;
	cin>>n;
	vector<vector<int>> a;
	for(int i = 1;i <= n;i++)
	{
		vector<int> b(i);
		for(int j = 0;j < i;j++)
			cin>>b[j];
		a.push_back(b);
	}
	int ans = solution(n, a);
	cout<<ans;
	return 0;
}

